import Vue from 'vue'
import Router from 'vue-router'
import Home from '@/pages/home/home'
import Square from '@/pages/square/square'
import Main from '@/pages/main/main'
import RecommendDetail from '@/pages/recommendDetail/recommendDetail' //热销商品详情
import FarmerApply from '@/pages/farmerApply/farmerApply' //农户申请
import Individual from '@/pages/farmerApply/individual' //个人申请
import AssociationList from '@/pages/farmerApply/associationList' //协会申请列表
import AssociationDetail from '@/pages/farmerApply/associationDetail' //协会申请详情 farmerAudit
import FarmerAudit from '@/pages/farmerAudit/farmerAudit' //审核页面
import Personal from '@/pages/personal/personal' // 个人信息
import Product from '@/pages/product/product' // 我的产品
import ProductAdd from '@/pages/product/productAdd' // 添加产品
import MyAssociation from '@/pages/myAssociation/myAssociation' // 我的协会
import MyDetail from '@/pages/myAssociation/myDetail' // 我的协会详情
import Optional from '@/pages/optional/optional' // 选配商品
import Login from '@/pages/index/login' //登录界面
import Register from '@/pages/index/register'
Vue.use(Router)

//默认不需要权限的页面
export const constantRouterMap = [{
  path: '/',
  name: 'home',
  component: Home
},
{
  path: '/register',
  name: 'register',
  component: Register
},
{
  path: '/login',
  name: 'login',
  component: Login
},
{
  path: "/home",
  name: 'home',
  component: Home,
},
{
  path: "/square",
  name: 'square',
  component: Square,
},
{
  path: "/main",
  name: 'main',
  component: Main,
},
{
  path: '/recommendDetail/:id',
  name: 'recommendDetail',
  component: RecommendDetail
},
{
  path: '/farmerApply',
  name: 'farmerApply',
  component: FarmerApply
},
{
  path: '/individual',
  name: 'individual',
  component: Individual
},
{
  path: '/associationList',
  name: 'associationList',
  component: AssociationList
},
{
  path: '/associationDetail',
  name: 'associationDetail',
  component: AssociationDetail
},
{
  path: '/farmerAudit',
  name: 'farmerAudit',
  component: FarmerAudit
},
{
  path: '/personal',
  name: 'personal',
  component: Personal
},
{
  path: '/product',
  name: 'product',
  component: Product
},
{
  path: '/productAdd',
  name: 'productAdd',
  component: ProductAdd
},
{
  path: '/myAssociation',
  name: 'myAssociation',
  component: MyAssociation
},
{
  path: '/myDetail',
  name: 'myDetail',
  component: MyDetail
},
{
  path: '/optional',
  name: 'optional',
  component: Optional
},
]


//注册路由
export default new Router({

  mode: 'history', // 默认为'hash'模式history
  routes: constantRouterMap,
  scrollBehavior: (to, from, savedPosition) => {
    if (savedPosition) {
      return savedPosition;
    } else {
      return {
        x: 0,
        y: 0
      };
    }
  },
})